#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r;
	cin>>n>>l>>r;
	int cnt=-1;
	for(int k=r;k>=l;k--)
	{
		int s=k%n;
		if(s>cnt) cnt=s;
	}
	cout<<cnt<<endl;
	return 0;
}
